#include "main.h"
typedef struct Queue1 {
    int* front;
    int* rear;
}Queue1;
Queue1 b;
int init_queue(Queue** q) {
    (*q) = (Queue*)malloc(sizeof(Queue));
    if (!*q) {
        return 1;
    }
    b.front = (*q)->elements;
    (*q)->size = 0;
    b.rear = b.front;
    return 0;
};
int enqueue(Queue* q, int value) {
    if (q->size > QUEUE_MAX_SIZE) {
        return 1;
    }
    b.rear++;
    q->elements[q->size] = value;
    q->size++;
    return 0;
};
int dequeue(Queue* q, int* value) {
    if (b.front == b.rear) {
        return 1;
    }
    *value = *(b.front);

    b.front++;
    q->size--;
    return 0;
};
int first(Queue* q, int* value) {
    if (b.front == b.rear) {
        return 1;
    }
    *value = *(b.front);
    return 0;
};
int is_empty(Queue* q) {
    if (q->size == 0)
        return 0;
    return 1;
}
int size(Queue* q) {
    return q->size;
};
int main() {
    Queue* q;
    int value;
    init_queue(&q);
    for (int i = 2; i < 5; ++i) {
        if (enqueue(q, i)) {
            printf("error");
            break;
        }
        first(q, &value);
        printf("value=%d ", value);
    }
    dequeue(q, &value);
    first(q, &value);
    printf("value=%d\n", value);
    printf("%d\n", size(q));
    printf("%d", is_empty(q));
}